#!/usr/bin/env python
#coding: utf-8
#
import time
from plugins import plugins_api
from redishelper import RedisHelper
import json
redis_cli = RedisHelper()
hostname = 'linxu.cc'
# config = {
# 	'load':{
# 			'interval':5,
# 			'plugin_name':'get_load_inof',
# 			'last_time':0
# 	},

# }
# config = json.loads(redis_cli.get('temmplate_1'))

config = json.loads(redis_cli.get('template_1'))

while True:
	for key,value in config.items():
		currenttime,interval,last_time = time.time(),value['interval'],value['last_time']
		if currenttime - last_time < interval:
			pass
		else:
			plugin_name = value['plugin_name']
			func = getattr(plugins_api,plugin_name)
			redis_cli.public(func(),'fm95.5')
			config[key]['last_time'] = currenttime